﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Data.Entity;

namespace Repository
{
    public class Repo<T>: IRepository<T> where T: class
    {
        protected DbSet<T> DbSet;

        public Repo(DbContext dbContext)
        {
            DbSet = dbContext.Set<T>();
        }

        public void Insert(T entity)
        {
            DbSet.Add(entity);
        }

        public void Delete(T entity)
        {
            ;
        }

        public IQueryable<T> SearchFor(Expression<Func<T, bool>> predicate)
        {
            return DbSet.Where(predicate);
        }

        public IQueryable<T> GetAll()
        {
            return DbSet;
        }

        public T GetByID(int ID)
        {
            return DbSet.Find(ID);
        }

    }
}